<?php 
class History extends CI_Controller
{
	public function index()
	{
		//load model
		$this->load->model('History_model');
		
		//set variable
		$memid = $this->session->userdata('memid');
		
		$data['myhistory'] = $this->History_model->myhistory($memid);
		
		$this->load->view('template/header');
		$this->load->view('myhistory', $data);
		$this->load->view('template/footer');
	}
	
	public function ajax_status()
	{
		//load model
		$this->load->model('History_model');
		
		//get variable
		$memid = $this->session->userdata('memid');
		
		$status_type = $this->input->post('ajax_print_type');
		if($status_type == 'all'){
			$data['myhistory'] = $this->History_model->myhistory($memid);
		}
		else if($status_type == 'approve'){
			$resstatus = 1;
			$data['myhistory'] = $this->History_model->get_by_status($memid, $resstatus);
		}
		else if($status_type == 'unapprove'){
			$resstatus = 0;
			$data['myhistory'] = $this->History_model->get_by_status($memid, $resstatus);
		}
		
		echo $this->load->view('myhistory_template' ,$data);
	}
}